<?php

namespace core;

class  HttpSession implements Object{

	private static $HTTP_SESSION;
	private static $PARAMETERS;

	public static function getInstance(){
		if(!(static::$HTTP_SESSION instanceof HttpSession)){
			new HttpSession();
		}
		return static::$HTTP_SESSION;
	}

	public function __construct(){
		$this->initParament();
		static::$HTTP_SESSION = $this;
	}

	private function initParament(){
		static::$PARAMETERS = array();
		if(is_array($_REQUEST) && !empty($_REQUEST)){
			foreach ($_REQUEST as $key =>  $value){
				static::$PARAMETERS[$key] = $value;
			}
			unset($_REQUEST);
		}
	}

	public function hasParameter($name){
		if(array_key_exists($name, static::$PARAMETERS)){
			return true;
		}
		return false;
	}

	public function getParameter($name){
		if (!$this->hasParameter($name)){
			throw new \Exception("Erro: Invalid Parameter");
		}
		return static::$PARAMETERS[$name];
	}

	public function setParameter($name, $value){
		return static::$PARAMETERS[$name] = $value;
	}
}
?>